<?php
    include('../../session.inc');
    if(file_exists('../../../definitions.inc.php')) include_once('../../../definitions.inc.php');
    require_once('../../funct.inc');
    //--------------------MODUL LOGS--------------------------------------
    if (file_exists("modules/logs/logs.inc"))
	    require_once("modules/logs/logs.inc");
    //--------------------------------------------------------------------

    if(!GetAdminID($ID)){echo LOGIN_ERR;exit;}
    if(!Right_Check(2)){header('Location:../../error.php');exit;}
    
    include '../../color_style.php';
    include '../../'.LANGUAGE;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
	    <?php echo '<meta http-equiv="Content-Type" content="text/html; charset='._CHARSET_.';">'; ?>
		<?php 
			include '../../html_style.php';
		?>
	</head>

<?php
	print "<body style=\"background-color:".Background_Color.";\">";

	require_once('../../../classDB.inc.php');
	require_once('../../functs.inc');
	
	do
	{
	    $_DB = new classDB();
            if (!$_DB->open()){echo OPEN_DB_ERR; break;}
		
		
		//ulozenie zmien
		if(
			 ($_REQUEST['Save_Options']=="YES") AND
			 (is_numeric($_REQUEST['Expiration']))
			)
		{
			mysql_query("
				UPDATE `invoice_options` 
                SET
                    Prefix		= '".$_REQUEST['Prefix']."',
                    Expiration	=  ".$_REQUEST['Expiration'].",
                    Constant_Symbol = '".$_REQUEST['Constant_Symbol']."',
                    Additorial_Text = '".$_REQUEST['Additorial_Text']."',
                    Payment_Type	= '".$_REQUEST['Payment_Type']."',
                    Active          = '".$_REQUEST['Active']."';
					
			");
            file_put_contents('../../address.txt',$_REQUEST['Address']);
			print "<b style=\"color:green;\">".INV_UDAJE_BOLI_ULOZENE."</b>";
		}
		else{
			if (
			 ($_REQUEST['Save_Options']=="YES") AND
			 (!is_numeric($_REQUEST['Expiration']))
			)
			print INV_POCET_DNI_SLPLATNOSTI_MUSI_BYT_CISLO;
		}
		
		//nadefinovanie hodnot z db
		$sql_obj = mysql_fetch_object((mysql_query("select * from invoice_options")));		
		$Prefix			= $sql_obj->Prefix;
		$Expiration		= $sql_obj->Expiration;
		$Constant_Symbol	= $sql_obj->Constant_Symbol;
		$Payment_Type		= $sql_obj->Payment_Type;
		$Additorial_Text	= $sql_obj->Additorial_Text;
                $Address                = file_get_contents('../../address.txt');
                if(trim($sql_obj->Active)=="1")
                  $Active = "checked";
                else
                  $Active = "";
                
		 	
	    
	    print "
		    <form action=\"invoice_options.php\" method=\"post\" target=\"place\">
		    	<br />
		    	<br />
		    	<b>".INV_NASTAVENIE_FAKTURACNYCH_PREDVOLIEB.":</b>
				<br />
				<br />
		    	<table>
                                <tr>
		    			<td colspan=\"2\" style=\"border:3px solid black;\">		    				
		    				<input type=\"checkbox\" name=\"Active\" value=\"1\" ".$Active." />
                                                ".INV_AKTIVOVAT_VYTVARANIE_FAKTUR."
		    			</td>
		    		</tr>
		    		<tr>
		    			<td>
		    				".INV_PREDCISLIE."
		    			</td>
		    			<td>
		    				<input type=\"text\" name=\"Prefix\" value=\"$Prefix\" />
		    			</td>
		    		</tr>
		    		<tr>
		    			<td>
		    				".INV_POCET_DNI_SPLATNOSTI."
		    			</td>
		    			<td>
		    				<input type=\"text\" name=\"Expiration\" value=\"$Expiration\" />
		    			</td>
		    		</tr>
		    		<tr>
		    			<td>
		    				".INV_KONSTANTNY_SYMBOL2."
		    			</td>
		    			<td>
		    				<input type=\"text\" name=\"Constant_Symbol\" value=\"$Constant_Symbol\" />
		    			</td>
		    		</tr>
		    		<tr>
		    			<td>
		    				".INV_SPOSOB_PLATBY2."
		    			</td>
		    			<td>
		    				<input type=\"text\" name=\"Payment_Type\" value=\"$Payment_Type\" />
                                                <small>".INV_AK_NIE_JE_ZADANY_TYP_PLATBY_POUZIJE_SA_TYP_DEFINOVANY_V_OBJEDNAVKE."<small>
		    			</td>
		    		</tr>
		    		<tr>
		    			<td>
		    				".INV_DOPLNUJUCI_TEXT."
		    			</td>
		    			<td>
		    				<textarea name=\"Additorial_Text\" style=\"width:300px;height:100px;\">$Additorial_Text</textarea>
		    			</td>
		    		</tr>
                                <tr>
		    			<td>
		    				".INV_ADRESA_A_KONTAKTNE_UDAJE."
		    			</td>
		    			<td>
		    				<textarea name=\"Address\" style=\"width:300px;height:100px;\">$Address</textarea>
		    			</td>
		    		</tr>
				<tr>
		    			<td colspan=\"2\">
		    				<input type=\"hidden\" name=\"Save_Options\" value=\"YES\" />
		    				<input type=\"submit\" value=\"".INV_ULOZIT_ZMENY."\" />
		    			</td>
		    		</tr>		    	
		    	</table>
		    </form>
		    <br />
			<br />
			<br />
			<form action=\"invoice_year_switch.php\" method=\"post\" target=\"place\">
				<input type=\"submit\" value=\"".INV_VYKONAT_ROCNY_PREVOD."\" />
			</form>				
	    ";
	    
	
	    mysql_close();
	}
	while(false);
?>


</body>
</html>
